package com.fqgj.xjd.user.service;

import com.fqgj.xjd.user.client.response.XueXinUserDetails;
import com.fqgj.xjd.user.dao.UserAuthAccountDao;
import com.fqgj.xjd.user.dao.UserAuthXuexinDao;
import com.fqgj.xjd.user.entity.UserAuthXuexinEntity;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: sm
 * Date: 2017/2/26
 * Time: 下午4:03
 */
@Service
public class UserAuthXueXinService {

    @Autowired
    private UserAuthXuexinDao userAuthXuexinDao;


    @Autowired
    UserAuthAccountDao userAuthAccountDao;


    public UserAuthXuexinEntity selectXueXinByUserCode(String userCode){
        return userAuthXuexinDao.selectXueXinByUserCode(userCode);
    }



    public void saveUserXueXin(String userCode, List<XueXinUserDetails> xxuds, String username, String password){
        int i = 0;
        for (XueXinUserDetails xxud : xxuds) {
            UserAuthXuexinEntity entity = new UserAuthXuexinEntity();
            BeanUtils.copyProperties(xxud, entity);
            entity.setType(i + 1);
            entity.setUserCode(userCode);
            userAuthXuexinDao.insert(entity);
            ++i;
        }
    }

}
